package com.lmscn.lms.api.model;

import com.jfinal.plugin.activerecord.Db;
import com.jfinal.plugin.activerecord.Model;

/**
 * Created by Czl on 2015/7/24.
 */
@SuppressWarnings("serial")
public class SysUser extends Model<SysUser> {

    public static final SysUser dao = new SysUser();

    /**
          * 登陆
     * @param username
     * @param password
     * @return
     */
    public SysUser getLoginUser(String username,String password){
        String sql = "select * from sys_user where username=? and password=? ";
        return findFirst(sql,username,password);
    }

    /**
     * 修改密码
     * @param userId
     * @param newPassword
     * @return
     */
    public int resetPassword(Long userId,String newPassword){
        return Db.update("update sys_user set password = ? where id=?",newPassword,userId);
    }
}
